<?php include template('header','admin');?>
	<body>
		<div class="fixed-nav layout">
			<ul>
				<li class="first">添加商家分组</li>
				<li class="spacer-gray"></li>
			</ul>
			<div class="hr-gray"></div>
		</div>
		<div class="content padding-big have-fixed-nav">
			<form name="form" action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" enctype="multipart/form-data">
			<div class="form-box clearfix">
				<?php echo Form::input('text', 'title', $title, '商家分组名称：', '请输入自定义分组名称，比如厂家直销', array('datatype' => '*')); ?>
                <?php echo Form::input('text', 'description', $description, '描述：', '请输商家分组相关描述内容', array('datatype' => '*')); ?>
                <?php echo Form::input('text', 'sort', $sort, '排序：','', array('datatype' => '*')); ?>
				<div class="form-group">
					<span class="label">分组状态：</span>
					<div class="box">
						<label class="select-wrap">
							<input class="select-btn" type="radio" <?php if($status == 1 || $status == null){?>checked=""<?php }?> value="1" name="status">开启
						</label>
						<label class="select-wrap">
							<input class="select-btn" type="radio" <?php if($status == 0){?>checked=""<?php }?> value="0" name="status">锁定
						</label>
					<br>
					</div>
					<p class="desc">请设置商家分组状态，默认为开启。</p>
				</div>

			<div class="padding">
				<?php if(isset($id)):?>
					<input type="hidden" name="id" value="<?php echo $id?>" />
				<?php endif;?>
				<input type="hidden" name="type" value="" />
				<input type="submit" class="button bg-main" value="保存" />
				<input type="button" class="button margin-left bg-gray" value="返回" />
			</div>
			</form>
		</div>
		<script type="text/javascript">
			$(window).otherEvent();
			var group_json = <?php echo json_encode($group_format)?>;
			//切换效果

			function loadBegin(group_type){
				$('input[name="type"]').val(group_type);
				if(group_type=="0"){
					$(".form-group:eq(4)").show();
					$(".form-group:eq(5)").hide();
				}else{
					$(".form-group:eq(4)").hide();
					$(".form-group:eq(5)").show();
				}
			}
			$(function(){
			     $('.form-group:last-child').addClass('last-group');
                 
				//模拟第一个点击
				if($('input[name="group_id"]').val()=='')$('.listbox-items span:eq(0)').trigger('click');
                
				var group_type = group_json.type[parseInt($("input[name='group_id']").val())];
                
				loadBegin(group_type);
                
				$('input[name="group_id"]').live('change', function() {
					group_type = group_json.type[parseInt($(this).val())];
					loadBegin(group_type);
				}); 
        }); 
		</script>
	</body>
</html>